﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class lexicographicallyComparison
{
    static void Main()
    {
        //Int string and enter string from console
        Console.Write("Enter A Word: ");
        string firstWord = Console.ReadLine();
        Console.Write("Enter B Word: ");
        string secondWord = Console.ReadLine(); 
        //Convert string to char Array;
        char[] firstWordArry = firstWord.ToCharArray();
        char[] secondWordArry = secondWord.ToCharArray();
        
        //Find max arr lenght
        int maxLenght = firstWordArry.Length;
        if (secondWordArry.Length > firstWordArry.Length)
        {
            maxLenght = secondWordArry.Length;
        }
        //copy char arrys to new char Arr with max lenght
        char[] aArr = new char[maxLenght];
        char[] bArr = new char[maxLenght];
        Array.Copy(firstWordArry, aArr, firstWordArry.Length);
        Array.Copy(secondWordArry, bArr, secondWordArry.Length);
        char[] smallWord = new char[maxLenght];
        smallWord = aArr;
        for (int elements = 0; elements < maxLenght; elements++)
        {
            if (aArr[elements] == 0)
            {
                break;
            }
            if (bArr[elements] == 0) 
            {
                smallWord = bArr;
                secondWordArry = aArr;
                break;
            }
            if (bArr[elements] < aArr[elements])
            {
                smallWord = bArr;
                secondWordArry = aArr;
                break;
            }
            break;
        }
        string first = new string(smallWord);
        string second = new string(secondWordArry);
        Console.WriteLine(first);
        Console.WriteLine(second);
    }
}

